home *** CD-ROM | disk | FTP | other *** search
/ AmigActive 21 / AACD 21.iso / AACD / Utilities / Ghostscript / src / gspath1.c < prev    next >
Encoding:
C/C++ Source or Header  |  2001-01-01  |  16.2 KB  |  584 lines

  1. /* Copyright (C) 1989, 1995, 1996, 1997, 1998, 1999 Aladdin Enterprises.  All rights reserved.
  2.   
  3.   This file is part of AFPL Ghostscript.
  4.   
  5.   AFPL Ghostscript is distributed with NO WARRANTY OF ANY KIND.  No author or
  6.   distributor accepts any responsibility for the consequences of using it, or
  7.   for whether it serves any particular purpose or works at all, unless he or
  8.   she says so in writing.  Refer to the Aladdin Free Public License (the
  9.   "License") for full details.
  10.   
  11.   Every copy of AFPL Ghostscript must include a copy of the License, normally
  12.   in a plain ASCII text file named PUBLIC.  The License grants you the right
  13.   to copy, modify and redistribute AFPL Ghostscript, but only under certain
  14.   conditions described in the License.  Among other things, the License
  15.   requires that the copyright notice and this notice be preserved on all
  16.   copies.
  17. */
  18.  
  19. /*$Id: gspath1.c,v 1.2.2.1 2000/12/04 21:10:27 raph Exp $ */
  20. /* Additional PostScript Level 1 path routines for Ghostscript library */
  21. #include "math_.h"
  22. #include "gx.h"
  23. #include "gserrors.h"
  24. #include "gsstruct.h"
  25. #include "gxfixed.h"
  26. #include "gxfarith.h"
  27. #include "gxmatrix.h"
  28. #include "gzstate.h"
  29. #include "gspath.h"
  30. #include "gzpath.h"
  31. #include "gscoord.h"        /* gs_itransform prototype */
  32.  
  33. /* ------ Arcs ------ */
  34.  
  35. /* Conversion parameters */
  36. #define degrees_to_radians (M_PI / 180.0)
  37.  
  38. typedef enum {
  39.     arc_nothing,
  40.     arc_moveto,
  41.     arc_lineto
  42. } arc_action;
  43.  
  44. typedef struct arc_curve_params_s {
  45.     /* The following are set once. */
  46.     gx_path *ppath;
  47.     gs_imager_state *pis;
  48.     gs_point center;        /* (not used by arc_add) */
  49.     double radius;
  50.     /* The following may be updated dynamically. */
  51.     arc_action action;
  52.     segment_notes notes;
  53.     gs_point p0, p3, pt;
  54.     gs_sincos_t sincos;        /* (not used by arc_add) */
  55.     fixed angle;        /* (not used by arc_add) */
  56.     int fast_quadrant;        /* 0 = not calculated, -1 = not fast, */
  57.                 /* 1 = fast (only used for quadrants) */
  58.     /* The following are set once iff fast_quadrant > 0. */
  59.     fixed scaled_radius;    /* radius * CTM scale */
  60.     fixed quadrant_delta;    /* scaled_radius * quarter_arc_fraction */
  61. } arc_curve_params_t;
  62.  
  63. /* Forward declarations */
  64. private int arc_add(P2(const arc_curve_params_t *arc, bool is_quadrant));
  65.  
  66. int
  67. gs_arc(gs_state * pgs,
  68.        floatp xc, floatp yc, floatp r, floatp ang1, floatp ang2)
  69. {
  70.     return gs_arc_add_inline(pgs, false, xc, yc, r, ang1, ang2, true);
  71. }
  72.  
  73. int
  74. gs_arcn(gs_state * pgs,
  75.     floatp xc, floatp yc, floatp r, floatp ang1, floatp ang2)
  76. {
  77.     return gs_arc_add_inline(pgs, true, xc, yc, r, ang1, ang2, true);
  78. }
  79.  
  80. int
  81. gs_arc_add(gs_state * pgs, bool clockwise, floatp axc, floatp ayc,
  82.        floatp arad, floatp aang1, floatp aang2, bool add_line)
  83. {
  84.     return gs_arc_add_inline(pgs, clockwise, axc, ayc, arad,
  85.                  aang1, aang2, add_line);
  86. }
  87.  
  88. /* Compute the next curve as part of an arc. */
  89. private int
  90. next_arc_curve(arc_curve_params_t * arc, fixed anext)
  91. {
  92.     double x0 = arc->p0.x = arc->p3.x;
  93.     double y0 = arc->p0.y = arc->p3.y;
  94.     double trad = arc->radius *
  95.     tan(fixed2float(anext - arc->angle) *
  96.         (degrees_to_radians / 2));
  97.  
  98.     arc->pt.x = x0 - trad * arc->sincos.sin;
  99.     arc->pt.y = y0 + trad * arc->sincos.cos;
  100.     gs_sincos_degrees(fixed2float(anext), &arc->sincos);
  101.     arc->p3.x = arc->center.x + arc->radius * arc->sincos.cos;
  102.     arc->p3.y = arc->center.y + arc->radius * arc->sincos.sin;
  103.     arc->angle = anext;
  104.     return arc_add(arc, false);
  105. }
  106. /*
  107.  * Use this when both arc.angle and anext are multiples of 90 degrees,
  108.  * and anext = arc.angle +/- 90.
  109.  */
  110. private int
  111. next_arc_quadrant(arc_curve_params_t * arc, fixed anext)
  112. {
  113.     double x0 = arc->p0.x = arc->p3.x;
  114.     double y0 = arc->p0.y = arc->p3.y;
  115.  
  116.     if (!arc->fast_quadrant) {
  117.     /*
  118.      * If the CTM is well-behaved, we can pre-calculate the delta
  119.      * from the arc points to the control points.
  120.      */
  121.     const gs_imager_state *pis = arc->pis;
  122.     double scale;
  123.  
  124.     if (is_fzero2(pis->ctm.xy, pis->ctm.yx) ?
  125.         (scale = fabs(pis->ctm.xx)) == fabs(pis->ctm.yy) :
  126.         is_fzero2(pis->ctm.xx, pis->ctm.yy) ?
  127.         (scale = fabs(pis->ctm.xy)) == fabs(pis->ctm.yx) :
  128.         0
  129.         ) {
  130.         double scaled_radius = arc->radius * scale;
  131.  
  132.         arc->scaled_radius = float2fixed(scaled_radius);
  133.         arc->quadrant_delta =
  134.         float2fixed(scaled_radius * quarter_arc_fraction);
  135.         arc->fast_quadrant = 1;
  136.     } else {
  137.         arc->fast_quadrant = -1;
  138.     }
  139.     }
  140.     /*
  141.      * We know that anext is a multiple of 90 (as a fixed); we want
  142.      * (anext / 90) & 3.  The following is much faster than a division.
  143.      */
  144.     switch ((fixed2int(anext) >> 1) & 3) {
  145.     case 0:
  146.     arc->sincos.sin = 0, arc->sincos.cos = 1;
  147.     arc->p3.x = x0 = arc->center.x + arc->radius;
  148.     arc->p3.y = arc->center.y;
  149.     break;
  150.     case 1:
  151.     arc->sincos.sin = 1, arc->sincos.cos = 0;
  152.     arc->p3.x = arc->center.x;
  153.     arc->p3.y = y0 = arc->center.y + arc->radius;
  154.     break;
  155.     case 2:
  156.     arc->sincos.sin = 0, arc->sincos.cos = -1;
  157.     arc->p3.x = x0 = arc->center.x - arc->radius;
  158.     arc->p3.y = arc->center.y;
  159.     break;
  160.     case 3:
  161.     arc->sincos.sin = -1, arc->sincos.cos = 0;
  162.     arc->p3.x = arc->center.x;
  163.     arc->p3.y = y0 = arc->center.y - arc->radius;
  164.     break;
  165.     }
  166.     arc->pt.x = x0, arc->pt.y = y0;
  167.     arc->angle = anext;
  168.     return arc_add(arc, true);
  169. }
  170.  
  171. int
  172. gs_imager_arc_add(gx_path * ppath, gs_imager_state * pis, bool clockwise,
  173.         floatp axc, floatp ayc, floatp arad, floatp aang1, floatp aang2,
  174.           bool add_line)
  175. {
  176.     double ar = arad;
  177.     fixed ang1 = float2fixed(aang1), ang2 = float2fixed(aang2), anext;
  178.     double ang1r;        /* reduced angle */
  179.     arc_curve_params_t arc;
  180.     int code;
  181.  
  182.     arc.ppath = ppath;
  183.     arc.pis = pis;
  184.     arc.center.x = axc;
  185.     arc.center.y = ayc;
  186. #define fixed_90 int2fixed(90)
  187. #define fixed_180 int2fixed(180)
  188. #define fixed_360 int2fixed(360)
  189.     if (ar < 0) {
  190.     ang1 += fixed_180;
  191.     ang2 += fixed_180;
  192.     ar = -ar;
  193.     }
  194.     arc.radius = ar;
  195.     arc.action = (add_line ? arc_lineto : arc_moveto);
  196.     arc.notes = sn_none;
  197.     arc.fast_quadrant = 0;
  198.     ang1r = fixed2float(ang1 % fixed_360);
  199.     gs_sincos_degrees(ang1r, &arc.sincos);
  200.     arc.p3.x = axc + ar * arc.sincos.cos;
  201.     arc.p3.y = ayc + ar * arc.sincos.sin;
  202.     if (clockwise) {
  203.     while (ang1 < ang2)
  204.         ang2 -= fixed_360;
  205.     if (ang2 < 0) {
  206.         fixed adjust = ROUND_UP(-ang2, fixed_360);
  207.  
  208.         ang1 += adjust, ang2 += adjust;
  209.     }
  210.     arc.angle = ang1;
  211.     if (ang1 == ang2)
  212.         goto last;
  213.     /* Do the first part, up to a multiple of 90 degrees. */
  214.     if (!arc.sincos.orthogonal) {
  215.         anext = ROUND_DOWN(arc.angle - fixed_epsilon, fixed_90);
  216.         if (anext < ang2)
  217.         goto last;
  218.         code = next_arc_curve(&arc, anext);
  219.         if (code < 0)
  220.         return code;
  221.         arc.action = arc_nothing;
  222.         arc.notes = sn_not_first;
  223.     }        
  224.     /* Do multiples of 90 degrees.  Invariant: ang1 >= ang2 >= 0. */
  225.     while ((anext = arc.angle - fixed_90) >= ang2) {
  226.         code = next_arc_quadrant(&arc, anext);
  227.         if (code < 0)
  228.         return code;
  229.         arc.action = arc_nothing;
  230.         arc.notes = sn_not_first;
  231.     }
  232.     } else {
  233.     while (ang2 < ang1)
  234.         ang2 += fixed_360;
  235.     if (ang1 < 0) {
  236.         fixed adjust = ROUND_UP(-ang1, fixed_360);
  237.  
  238.         ang1 += adjust, ang2 += adjust;
  239.     }
  240.     arc.angle = ang1;
  241.     if (ang1 == ang2)
  242.         return next_arc_curve(&arc, ang2);
  243.     /* Do the first part, up to a multiple of 90 degrees. */
  244.     if (!arc.sincos.orthogonal) {
  245.         anext = ROUND_UP(arc.angle + fixed_epsilon, fixed_90);
  246.         if (anext > ang2)
  247.         goto last;
  248.         code = next_arc_curve(&arc, anext);
  249.         if (code < 0)
  250.         return code;
  251.         arc.action = arc_nothing;
  252.         arc.notes = sn_not_first;
  253.     }        
  254.     /* Do multiples of 90 degrees.  Invariant: 0 <= ang1 <= ang2. */
  255.     while ((anext = arc.angle + fixed_90) <= ang2) {
  256.         code = next_arc_quadrant(&arc, anext);
  257.         if (code < 0)
  258.         return code;
  259.         arc.action = arc_nothing;
  260.         arc.notes = sn_not_first;
  261.     }
  262.     }
  263.     /*
  264.      * Do the last curve of the arc, if any.
  265.      */
  266.     if (arc.angle == ang2)
  267.     return 0;
  268. last:
  269.     return next_arc_curve(&arc, ang2);
  270. }
  271.  
  272. int
  273. gs_arcto(gs_state * pgs,
  274. floatp ax1, floatp ay1, floatp ax2, floatp ay2, floatp arad, float retxy[4])
  275. {
  276.     double xt0, yt0, xt2, yt2;
  277.     gs_point up0;
  278.  
  279. #define ax0 up0.x
  280. #define ay0 up0.y
  281.     /* Transform the current point back into user coordinates. */
  282.     int code = gs_currentpoint(pgs, &up0);
  283.  
  284.     if (code < 0)
  285.     return code;
  286.     {                /* Now we have to compute the tangent points. */
  287.     /* Basically, the idea is to compute the tangent */
  288.     /* of the bisector by using tan(x+y) and tan(z/2) */
  289.     /* formulas, without ever using any trig. */
  290.     double dx0 = ax0 - ax1, dy0 = ay0 - ay1;
  291.     double dx2 = ax2 - ax1, dy2 = ay2 - ay1;
  292.  
  293.     /* Compute the squared lengths from p1 to p0 and p2. */
  294.     double sql0 = dx0 * dx0 + dy0 * dy0;
  295.     double sql2 = dx2 * dx2 + dy2 * dy2;
  296.  
  297.     /* Compute the distance from p1 to the tangent points. */
  298.     /* This is the only messy part. */
  299.     double num = dy0 * dx2 - dy2 * dx0;
  300.     double denom = sqrt(sql0 * sql2) - (dx0 * dx2 + dy0 * dy2);
  301.  
  302.     /* Check for collinear points. */
  303.     if (denom == 0) {
  304.         code = gs_lineto(pgs, ax1, ay1);
  305.         xt0 = xt2 = ax1;
  306.         yt0 = yt2 = ay1;
  307.     } else {        /* not collinear */
  308.         double dist = fabs(arad * num / denom);
  309.         double l0 = dist / sqrt(sql0), l2 = dist / sqrt(sql2);
  310.         arc_curve_params_t arc;
  311.  
  312.         arc.ppath = pgs->path;
  313.         arc.pis = (gs_imager_state *) pgs;
  314.         arc.radius = arad;
  315.         arc.action = arc_lineto;
  316.         arc.notes = sn_none;
  317.         if (arad < 0)
  318.         l0 = -l0, l2 = -l2;
  319.         arc.p0.x = xt0 = ax1 + dx0 * l0;
  320.         arc.p0.y = yt0 = ay1 + dy0 * l0;
  321.         arc.p3.x = xt2 = ax1 + dx2 * l2;
  322.         arc.p3.y = yt2 = ay1 + dy2 * l2;
  323.         arc.pt.x = ax1;
  324.         arc.pt.y = ay1;
  325.         code = arc_add(&arc, false);
  326.     }
  327.     }
  328.     if (retxy != 0) {
  329.     retxy[0] = xt0;
  330.     retxy[1] = yt0;
  331.     retxy[2] = xt2;
  332.     retxy[3] = yt2;
  333.     }
  334.     return code;
  335. }
  336.  
  337. /* Internal routine for adding an arc to the path. */
  338. private int
  339. arc_add(const arc_curve_params_t * arc, bool is_quadrant)
  340. {
  341.     gx_path *path = arc->ppath;
  342.     gs_imager_state *pis = arc->pis;
  343.     double x0 = arc->p0.x, y0 = arc->p0.y;
  344.     double xt = arc->pt.x, yt = arc->pt.y;
  345.     floatp fraction;
  346.     gs_fixed_point p0, p2, p3, pt;
  347.     int code;
  348.  
  349.     if ((arc->action != arc_nothing &&
  350.      (code = gs_point_transform2fixed(&pis->ctm, x0, y0, &p0)) < 0) ||
  351.     (code = gs_point_transform2fixed(&pis->ctm, xt, yt, &pt)) < 0 ||
  352.     (code = gs_point_transform2fixed(&pis->ctm, arc->p3.x, arc->p3.y, &p3)) < 0 ||
  353.     (code =
  354.      (arc->action == arc_nothing ?
  355.       (p0.x = path->position.x, p0.y = path->position.y, 0) :
  356.       arc->action == arc_lineto && path_position_valid(path) ?
  357.       gx_path_add_line(path, p0.x, p0.y) :
  358.       /* action == arc_moveto, or lineto with no current point */
  359.       gx_path_add_point(path, p0.x, p0.y))) < 0
  360.     )
  361.     return code;
  362.     /* Compute the fraction coefficient for the curve. */
  363.     /* See gx_path_add_partial_arc for details. */
  364.     if (is_quadrant) {
  365.     /* one of |dx| and |dy| is r, the other is zero */
  366.     fraction = quarter_arc_fraction;
  367.     if (arc->fast_quadrant > 0) {
  368.         /*
  369.          * The CTM is well-behaved, and we have pre-calculated the delta
  370.          * from the circumference points to the control points.
  371.          */
  372.         fixed delta = arc->quadrant_delta;
  373.  
  374.         if (pt.x != p0.x)
  375.         p0.x = (pt.x > p0.x ? p0.x + delta : p0.x - delta);
  376.         if (pt.y != p0.y)
  377.         p0.y = (pt.y > p0.y ? p0.y + delta : p0.y - delta);
  378.         p2.x = (pt.x == p3.x ? p3.x :
  379.             pt.x > p3.x ? p3.x + delta : p3.x - delta);
  380.         p2.y = (pt.y == p3.y ? p3.y :
  381.             pt.y > p3.y ? p3.y + delta : p3.y - delta);
  382.         goto add;
  383.     }
  384.     } else {
  385.     double r = arc->radius;
  386.     floatp dx = xt - x0, dy = yt - y0;
  387.     double dist = dx * dx + dy * dy;
  388.     double r2 = r * r;
  389.  
  390.     if (dist >= r2 * 1.0e8)    /* almost zero radius; */
  391.         /* the >= catches dist == r == 0 */
  392.         fraction = 0.0;
  393.     else
  394.         fraction = (4.0 / 3.0) / (1 + sqrt(1 + dist / r2));
  395.     }
  396.     p0.x += (fixed)((pt.x - p0.x) * fraction);
  397.     p0.y += (fixed)((pt.y - p0.y) * fraction);
  398.     p2.x = p3.x + (fixed)((pt.x - p3.x) * fraction);
  399.     p2.y = p3.y + (fixed)((pt.y - p3.y) * fraction);
  400. add:
  401.     if_debug8('r',
  402.           "[r]Arc f=%f p0=(%f,%f) pt=(%f,%f) p3=(%f,%f) action=%d\n",
  403.           fraction, x0, y0, xt, yt, arc->p3.x, arc->p3.y,
  404.           (int)arc->action);
  405.     /* Open-code gx_path_add_partial_arc_notes */
  406.     return gx_path_add_curve_notes(path, p0.x, p0.y, p2.x, p2.y, p3.x, p3.y,
  407.                    arc->notes | sn_from_arc);
  408. }
  409.  
  410. /* ------ Path transformers ------ */
  411.  
  412. int
  413. gs_dashpath(gs_state * pgs)
  414. {
  415.     gx_path *ppath;
  416.     gx_path fpath;
  417.     int code;
  418.  
  419.     if (gs_currentdash_length(pgs) == 0)
  420.     return 0;        /* no dash pattern */
  421.     code = gs_flattenpath(pgs);
  422.     if (code < 0)
  423.     return code;
  424.     ppath = pgs->path;
  425.     gx_path_init_local(&fpath, ppath->memory);
  426.     code = gx_path_add_dash_expansion(ppath, &fpath, (gs_imager_state *)pgs);
  427.     if (code < 0) {
  428.     gx_path_free(&fpath, "gs_dashpath");
  429.     return code;
  430.     }
  431.     gx_path_assign_free(pgs->path, &fpath);
  432.     return 0;
  433. }
  434.  
  435. int
  436. gs_flattenpath(gs_state * pgs)
  437. {
  438.     gx_path *ppath = pgs->path;
  439.     gx_path fpath;
  440.     int code;
  441.  
  442.     if (!gx_path_has_curves(ppath))
  443.     return 0;        /* nothing to do */
  444.     gx_path_init_local(&fpath, ppath->memory);
  445.     code = gx_path_add_flattened_accurate(ppath, &fpath, pgs->flatness,
  446.                       pgs->accurate_curves);
  447.     if (code < 0) {
  448.     gx_path_free(&fpath, "gs_flattenpath");
  449.     return code;
  450.     }
  451.     gx_path_assign_free(ppath, &fpath);
  452.     return 0;
  453. }
  454.  
  455. int
  456. gs_reversepath(gs_state * pgs)
  457. {
  458.     gx_path *ppath = pgs->path;
  459.     gx_path rpath;
  460.     int code;
  461.  
  462.     gx_path_init_local(&rpath, ppath->memory);
  463.     code = gx_path_copy_reversed(ppath, &rpath);
  464.     if (code < 0) {
  465.     gx_path_free(&rpath, "gs_reversepath");
  466.     return code;
  467.     }
  468.     gx_path_assign_free(ppath, &rpath);
  469.     return 0;
  470. }
  471.  
  472. /* ------ Accessors ------ */
  473.  
  474. int
  475. gs_upathbbox(gs_state * pgs, gs_rect * pbox, bool include_moveto)
  476. {
  477.     gs_fixed_rect fbox;        /* box in device coordinates */
  478.     gs_rect dbox;
  479.     int code = gx_path_bbox(pgs->path, &fbox);
  480.  
  481.     if (code < 0)
  482.     return code;
  483.     /* If the path ends with a moveto and include_moveto is true, */
  484.     /* include the moveto in the bounding box. */
  485.     if (path_last_is_moveto(pgs->path) && include_moveto) {
  486.     gs_fixed_point pt;
  487.  
  488.     gx_path_current_point_inline(pgs->path, &pt);
  489.     if (pt.x < fbox.p.x)
  490.         fbox.p.x = pt.x;
  491.     if (pt.y < fbox.p.y)
  492.         fbox.p.y = pt.y;
  493.     if (pt.x > fbox.q.x)
  494.         fbox.q.x = pt.x;
  495.     if (pt.y > fbox.q.y)
  496.         fbox.q.y = pt.y;
  497.     }
  498.     /* Transform the result back to user coordinates. */
  499.     dbox.p.x = fixed2float(fbox.p.x);
  500.     dbox.p.y = fixed2float(fbox.p.y);
  501.     dbox.q.x = fixed2float(fbox.q.x);
  502.     dbox.q.y = fixed2float(fbox.q.y);
  503.     return gs_bbox_transform_inverse(&dbox, &ctm_only(pgs), pbox);
  504. }
  505.  
  506. /* ------ Enumerators ------ */
  507.  
  508. /* Start enumerating a path */
  509. int
  510. gs_path_enum_copy_init(gs_path_enum * penum, const gs_state * pgs, bool copy)
  511. {
  512.     gs_memory_t *mem = pgs->memory;
  513.  
  514.     if (copy) {
  515.     gx_path *copied_path =
  516.     gx_path_alloc(mem, "gs_path_enum_init");
  517.     int code;
  518.  
  519.     if (copied_path == 0)
  520.         return_error(gs_error_VMerror);
  521.     code = gx_path_copy(pgs->path, copied_path);
  522.     if (code < 0) {
  523.         gx_path_free(copied_path, "gs_path_enum_init");
  524.         return code;
  525.     }
  526.     gx_path_enum_init(penum, copied_path);
  527.     penum->copied_path = copied_path;
  528.     } else {
  529.     gx_path_enum_init(penum, pgs->path);
  530.     }
  531.     penum->memory = mem;
  532.     gs_currentmatrix(pgs, &penum->mat);
  533.     return 0;
  534. }
  535.  
  536. /* Enumerate the next element of a path. */
  537. /* If the path is finished, return 0; */
  538. /* otherwise, return the element type. */
  539. int
  540. gs_path_enum_next(gs_path_enum * penum, gs_point ppts[3])
  541. {
  542.     gs_fixed_point fpts[3];
  543.     int pe_op = gx_path_enum_next(penum, fpts);
  544.     int code;
  545.  
  546.     switch (pe_op) {
  547.     case 0:        /* all done */
  548.     case gs_pe_closepath:
  549.         break;
  550.     case gs_pe_curveto:
  551.         if ((code = gs_point_transform_inverse(
  552.                               fixed2float(fpts[1].x),
  553.                               fixed2float(fpts[1].y),
  554.                           &penum->mat, &ppts[1])) < 0 ||
  555.         (code = gs_point_transform_inverse(
  556.                               fixed2float(fpts[2].x),
  557.                               fixed2float(fpts[2].y),
  558.                         &penum->mat, &ppts[2])) < 0)
  559.         return code;
  560.         /* falls through */
  561.     case gs_pe_moveto:
  562.     case gs_pe_lineto:
  563.         if ((code = gs_point_transform_inverse(
  564.                               fixed2float(fpts[0].x),
  565.                               fixed2float(fpts[0].y),
  566.                         &penum->mat, &ppts[0])) < 0)
  567.         return code;
  568.     default:        /* error */
  569.         break;
  570.     }
  571.     return pe_op;
  572. }
  573.  
  574. /* Clean up after a pathforall. */
  575. void
  576. gs_path_enum_cleanup(gs_path_enum * penum)
  577. {
  578.     if (penum->copied_path != 0) {
  579.     gx_path_free(penum->copied_path, "gs_path_enum_cleanup");
  580.     penum->path = 0;
  581.     penum->copied_path = 0;
  582.     }
  583. }
  584.